﻿using CloudSyncLib;
using CloudSyncLib.Storages;
using CloudSyncLib.Tasks;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace CloudSyncService
{
    public partial class SyncService : ServiceBase
    {
        public SyncService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {

            try
            {
                StartDBBackup();
            }
            catch (Exception ex) {
                Utils.Log(ex.ToString());
            }

        }

        DatabaseTask DBTask;

        private void StartDBBackup()
        {
            var settings = System.Configuration.ConfigurationManager.AppSettings;

            int val = int.Parse("DB.Interval");

            DBTask = DatabaseTask.Create();
            DBTask.RunWithInterval(val);
        }

        protected override void OnStop()
        {
        }
    }

}
